﻿

document.oncontextmenu = function() { return false }
document.ondragstart = new Function("return false");

function Resaltar_On(GridView) {
    try {
        if (GridView != null) {
            GridView.originalBgColor = GridView.style.backgroundColor;
            GridView.style.backgroundColor = "#DBE7F6";
        }
    } catch (e) {
        alert(e.message);
    }
}

function Resaltar_Off(GridView) {
    try {
        if (GridView != null) {
            GridView.style.backgroundColor = GridView.originalBgColor;
        }
    } catch (e) {
        alert(e.message);
    }
}

function Selected(row, rowID, grilla, idhidden) {
    var grid = document.getElementById(grilla);
    Limpiar(grid);
    row.style.backgroundColor = "#C2D6F3";
    row.style.fontWeight = "bold";
    document.getElementById(idhidden).value = rowID;
}
function Limpiar(grid) {
    for (i = 0; i < grid.rows.length; i++) {
        grid.rows[i].style.backgroundColor = grid.style.backgroundColor;
        grid.rows[i].style.fontWeight = "normal";
    }
}

function SelCambioEmpresa(Idimg, IdlblCod, IdlblName, img, codcli, name, IdMDI) {
    try {
        var left = getAbsoluteLeft("MDIP");
        var top = getAbsoluteTop("MDIP");
        var w = document.getElementById(IdMDI).style.width;
        var h = document.getElementById(IdMDI).style.height;
        progressIni(left, top, w, h);
        document.getElementById(Idimg).src = img;
        document.getElementById(IdlblCod).innerText = codcli;
        document.getElementById(IdlblName).innerText = name;
        document.getElementById(IdMDI).src =''; 
        //'GeneralInformation/GeneralInformation.aspx?pModo=M&cod=' + codcli + '';
        setTimeout("progressFin();", 3000);

    } catch (ex) {
        alert(ex.message);
    }
}

function getAbsoluteLeft(objectId) {
    // Get an object left position from the upper left viewport corner
    o = document.getElementById(objectId)
    oLeft = o.offsetLeft            // Get left position from the parent object
    while (o.offsetParent != null) {   // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent    // Get parent object reference
        oLeft += oParent.offsetLeft // Add parent left position
        o = oParent
    }
    return oLeft
}

function getAbsoluteTop(objectId) {
    // Get an object top position from the upper left viewport corner
    o = document.getElementById(objectId)
    oTop = o.offsetTop            // Get top position from the parent object
    while (o.offsetParent != null) { // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent  // Get parent object reference
        oTop += oParent.offsetTop // Add parent top position
        o = oParent
    }
    return oTop
}


function progressIni(lef, top, w, h) {
    try {
        document.getElementById("capaprincipal").style.visibility = 'visible';
        document.getElementById("capaprincipal").style.top = top;
        document.getElementById("capaprincipal").style.left = lef;
        document.getElementById("capaprincipal").style.width = w;
        document.getElementById("capaprincipal").style.height = h;
        document.body.style.cursor = "wait";
    } catch (ex) {
        alert(ex.message);
    }
}

function progressFin() {
    try {
        document.getElementById("capaprincipal").style.visibility = 'hidden';
        document.body.style.cursor = "Auto";
    } catch (ex) {
        alert(ex.message);
    }
}

function logout(pageajax) {
    try {
        var rpta = pageajax.Logout();
        if (!ErrorAjaxPro(rpta)) { return false; }
    } catch (ex) {
        alert(ex.message);
    }
}

function ErrorAjaxPro(objAjax) {
    try {
        //****************************************************
        if (objAjax.error != null) {
            switch (objAjax.error.Type) {
                case "System.IO.FileNotFoundException":
                    alert("Failed: " + objAjax.error.Message + " - " + objAjax.error.Type);
                    return false;
                    break;
                case "MyNamespace.MyException":
                    alert("Failed: " + objAjax.error.Message + " - " + objAjax.error.Type);
                    return false;
                    break;
                case "System.ArgumentException":
                    alert("Failed: " + objAjax.error.Message + " - " + objAjax.error.Type);
                    return false;
                    break;
            }
            alert("Failed: " + objAjax.error.Message + " - " + objAjax.error.Type);
            return false;
        }
        //****************************************************
        return true;
        //****************************************************
    } catch (ex) {
        alert(ex.message);
    }
}

//function ValidaIngreso(CaracteresPermitidos) {
//    try {
//        var key = String.fromCharCode(window.event.keyCode)
//        var valid = new String(CaracteresPermitidos)
//        var ok = false;
//        for (var i = 0; i < valid.length; i++) {
//            if (key == valid.substring(i, i + 1)) {
//                ok = true
//            }
//        }
//        if (!ok)
//            window.event.keyCode = 0
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function AbrirPopup(url, width, height) {
//    try {
//        var ventana;
//        //ventana = window.showModelessDialog(url, 'Popup', "scroll:no; location:no; resizable:yes; edge:Raised; status:no; dialogWidth:" + width + "px; dialogHeight:" + height + "px; center:yes; minimize:no");
//        ventana = window.showModalDialog(url, 'Popup', "scroll:no; location:no; resizable:no; edge:Raised; status:no; dialogWidth:" + width + "px; dialogHeight:" + height + "px; center:yes; minimize:no");
//    } catch (e) {
//        alert(e.message);
//    }
//}

//function AbrirFormCompany(idOpt,codigo) {
//    try {
//        var val = getCheckedRadio(document.getElementsByName(idOpt));
//        if (val == "C") { AbrirPopup('CompanyContact/AddCompanyContact.aspx?IdCompany='+ codigo +'&pModo=M', 940, 420); }
//        if (val == "V") { AbrirPopup('VendorContact/AddVendorContact.aspx?IdCompany='+ codigo +'&pModo=M', 940, 400); }
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function AddAbrirFormCompany(idOpt,codigo) {
//    try {
//        var val = getCheckedRadio(document.getElementsByName(idOpt));
//        if (val == "C") { AbrirPopup('../GeneralInformation/CompanyContact/AddCompanyContact.aspx?IdCompany='+ codigo +'&pModo=M', 940, 420); }
//        if (val == "V") { AbrirPopup('../GeneralInformation/VendorContact/AddVendorContact.aspx?IdCompany='+ codigo +'&pModo=M', 940, 400); }
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

function AbrirFrame(url, cod, idfram3, iddiv) {
    try {
        //var codcli = document.getElementById(cod).innerText;
        var codcli = "7";
        
        if (codcli == "") {
            alert('seleccione una empresa, por favor...');
        } else {
            var left = getAbsoluteLeft(iddiv);
            var top = getAbsoluteTop(iddiv);
            var w = document.getElementById(idfram3).style.width;
            var h = document.getElementById(idfram3).style.height;        
            progressIni(left, top, w, h);
            var url1 = url + '?cod=' + codcli
            document.getElementById(idfram3).src = url1;
            //ini();
            setTimeout("progressFin();", 2000);
        }

    } catch (ex) {
        alert(ex.message);
    }
}

//function getCheckedRadio(radioButtons) {
//    try {
//        for (var x = 0; x < radioButtons.length; x++) {
//            if (radioButtons[x].checked) {
//                return radioButtons[x].value;
//            }
//        }
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function ObtenerValOptiones(rbl) {
//    try {
//        var obj = rbl.id;
//        var items = 2
//        var rblChild = null;
//        for (i = 0; i < items; i++) {
//            rblChild = document.getElementById(obj + "_" + i.toString());
//            if (rblChild.checked) {
//                return rblChild.value;
//            }
//        }
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function ValidaIngreso(CaracteresPermitidos) {
//    try{
//	    var key = String.fromCharCode(window.event.keyCode)
//	    var valid = new String(CaracteresPermitidos)
//	    var ok = false;
//	    for (var i=0; i<valid.length; i++) {
//		    if (key == valid.substring(i,i+1)){
//			    ok = true
//		    }
//	    }        	
//	    if (!ok)	   
//		    window.event.keyCode=0		
//    }catch(ex){
//	    alert(ex.message);
//    }
//}

function extractNumber(obj, decimalPlaces, allowNegative) {
    var temp = obj.value;
    var reg0Str = '[0-9]*';
    
    if (decimalPlaces > 0) {
        reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
    } else if (decimalPlaces < 0) {
        reg0Str += '\\.?[0-9]*';
    }
    reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
    reg0Str = reg0Str + '$';
    var reg0 = new RegExp(reg0Str);
    if (reg0.test(temp)) return true;

    var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
    var reg1 = new RegExp(reg1Str, 'g');
    temp = temp.replace(reg1, '');

    if (allowNegative) {
        var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
        var reg2 = /-/g;
        temp = temp.replace(reg2, '');
        if (hasNegative) temp = '-' + temp;
    }

    if (decimalPlaces != 0) {
        var reg3 = /\./g;
        var reg3Array = reg3.exec(temp);
        if (reg3Array != null) {
            var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
            reg3Right = reg3Right.replace(reg3, '');
            reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
            temp = temp.substring(0, reg3Array.index) + '.' + reg3Right;
        }
    }

    obj.value = temp;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }

    if (isNaN(key)) return true;

    keychar = String.fromCharCode(key);

    if (key == 8 || isCtrl) {
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

    return isFirstN || isFirstD || reg.test(keychar);
}

//function conMayusculas(field) {
//    field.value = field.value.toUpperCase()
//}

//function MoneyFormat(amount) {
//    try {
//        var val = parseFloat(amount);
//        if (isNaN(val)) { return "0.00"; }
//        if (val <= 0) { return "0.00"; }
//        val += "";
//        // Next two lines remove anything beyond 2 decimal places 
//        if (val.indexOf('.') == -1) { return val + ".00"; }
//        else { val = val.substring(0, val.indexOf('.') + 3); }
//        val = (val == Math.floor(val)) ? val + '.00' : ((val * 10 == Math.floor(val * 10)) ? val + '0' : val);
//        return val;
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function validarEmail(valor) {
//    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
//        //alert('La dirección de email ' + valor + ' es correcta.')
//        return (true)
//    } else {
//        alert('La dirección de email es incorrecta.');
//        return (false);
//    }
//}

//function DivDisabled(el,valor) {
//    try {
//        el.disabled = valor;
//        //*************************************
//        //Busco todas las img y los desabilito
//        //*************************************
//        for (i = 0; ele = el.getElementsByTagName('img')[i]; i++)
//            ele.disabled = valor;
//        //*************************************        
//        
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function getCheckedRadio(radioButtons) {
//    try{
//        for (var x = 0; x < radioButtons.length; x++) {
//            if (radioButtons[x].checked) {
//                return radioButtons[x].value;
//            }
//        }
//    }catch(ex){
//        alert(ex.message);
//    }
//}

//function HabilitarControles(estado, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12, id13, id14, id15, id16, id17, id18, id19, idcontact){
//    try{
//        document.getElementById(id1).disabled = estado;
//        document.getElementById(id1).value = "";
//        document.getElementById(id2).disabled = estado;
//        document.getElementById(id2).parentNode.disabled = estado;
//        document.getElementById(id2).checked = false;
//        document.getElementById(id3).disabled = estado;
//        document.getElementById(id3).value = "";
//        document.getElementById(id4).disabled = estado;
//        document.getElementById(id5).disabled = estado;
//        document.getElementById(id5).value = "";
//        document.getElementById(id6).disabled = estado;
//        document.getElementById(id6).value = "";
//        document.getElementById(id7).disabled = estado;
//        document.getElementById(id7).value = "";
//        document.getElementById(id8).disabled = estado;
//        document.getElementById(id8).value = "";
//        document.getElementById(id9).disabled = estado;
//        document.getElementById(id9).value = "";
//        document.getElementById(id10).disabled = estado;
//        document.getElementById(id10).value = "";
//        document.getElementById(id11).disabled = estado;
//        document.getElementById(id11).value = "";
//        document.getElementById(id12).disabled = estado;
//        document.getElementById(id12).value = "";
//        document.getElementById(id13).disabled = estado;
//        document.getElementById(id14).disabled = estado;
//        document.getElementById(id15).disabled = estado;
//        document.getElementById(id15).value = "";
//        document.getElementById(id16).disabled = estado;
//        document.getElementById(id16).value = "";
//        document.getElementById(id17).disabled = estado;
//        document.getElementById(id18).disabled = estado;
//        document.getElementById(id18).parentNode.disabled = estado;
//        document.getElementById(id18).checked = false;
//        document.getElementById(id19).disabled = estado;
//        document.getElementById(id19).value = "Save";
//        document.getElementById(idcontact).innerText = ""  
//        
//    }catch(ex){
//        alert(ex.message);
//    } 
//}
function Cero(Monto)
{
if (Monto=='NaN' || Monto=='')
{
  return 0;
}
else
{
return  parseFloat(Monto);
}
}
//function HabilitarControlesVendorContacts(estado, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12, id13, id14, id15){
//    try{
//        document.getElementById(id1).innerText = "";
//        document.getElementById(id2).disabled = estado;
//        document.getElementById(id2).value = "";
//        document.getElementById(id3).disabled = estado;
//        document.getElementById(id3).parentNode.disabled = estado;
//        document.getElementById(id3).checked = false;
//        document.getElementById(id4).disabled = estado;
//        document.getElementById(id4).value = "";
//        document.getElementById(id5).disabled = estado;
//        document.getElementById(id5).value = "";
//        document.getElementById(id6).disabled = estado;
//        document.getElementById(id6).value = "";
//        document.getElementById(id7).disabled = estado;
//        document.getElementById(id7).value = "";
//        document.getElementById(id8).disabled = estado;
//        document.getElementById(id8).value = "";
//        document.getElementById(id9).disabled = estado;
//        document.getElementById(id9).value = "";
//        document.getElementById(id10).disabled = estado;
//        document.getElementById(id10).value = "";
//        document.getElementById(id11).disabled = estado;
//        document.getElementById(id11).value = "";
//        document.getElementById(id12).disabled = estado;
//        document.getElementById(id12).value = "";
//        document.getElementById(id13).disabled = estado;
//        document.getElementById(id14).disabled = estado;
//        document.getElementById(id15).value = "Save";
//        
//    }catch(ex){
//        alert(ex.message);
//    }
//}

//Create Budget
function TotalUnits(_txt, _txtUR
, _txtTU, _txtTotal, _txtUsageRate, _txtTotalUnits)
{
        try {
            var Total = 0;
            var TotalUR = 0;
            var TotalTU = 0;
            var Production = 0;
            var UsageRate = 0;
            for (i = 1; i <= 12; i++) {
                Production = 0;
                UsageRate = 0;
                if (document.getElementById(_txt + i).value.trim() != '' || document.getElementById(_txtUR + i).value.trim() != '') {

                    if (document.getElementById(_txt + i).value.trim() == '') {
                        document.getElementById(_txt + i).focus();
                        alert('Ingrese un Valor Para la Produccion');
                        return false;
                    }
                    if (document.getElementById(_txtUR + i).value.trim() == '') {
                        document.getElementById(_txtUR + i).focus();
                        alert('Ingrese un valor para el Usage Rate');
                        return false;
                    }
                    Production = redonder2Decimales(Cero(document.getElementById(_txt + i).value))
                    if (Production <= 0) {
                        alert('La production deber ser Mayor A Cero');
                        document.getElementById(_txt + i).focus();
                        return false;

                    }
                    UsageRate = redonder2Decimales(Cero(document.getElementById(_txtUR + i).value));
                    if (UsageRate <= 0) {
                        alert('El Usage Rate deber ser Mayor A Cero');
                        document.getElementById(_txtUR + i).focus();
                        return false;

                    }
                    if (UsageRate > Production) {
                        alert('El Usage Rate no puede ser Mayor a la Production');
                        document.getElementById(_txtUR + i).focus();
                        return false;


                    }
                    document.getElementById(_txtTU + i).value = redonder2Decimales(Production / UsageRate);
                    Total = redonder2Decimales(Cero(Total)) + redonder2Decimales(Cero(document.getElementById(_txt + i).value));
                    TotalUR = redonder2Decimales(Cero(TotalUR)) + redonder2Decimales(Cero(document.getElementById(_txtUR + i).value));
                    TotalTU = redonder2Decimales(Cero(TotalTU)) + redonder2Decimales((document.getElementById(_txtTU + i).value));

                }
                else {
                    document.getElementById(_txt + i).value = '';
                    document.getElementById(_txtUR  + i).value = '';
                    document.getElementById(_txtTU + i).value = '';
                
                }
               
            }
            document.getElementById(_txtTotal).value = redonder2Decimales(Total);
            document.getElementById(_txtUsageRate).value = redonder2Decimales(TotalUR);
            document.getElementById(_txtTotalUnits).value = redonder2Decimales(TotalTU);
            
        }
        catch (ex) {
            alert(ex.Message); 
     }   
}

function TotalCost(_txtTU,_txtUP,_txtTC,_TotalUnitPrice,_TotalCost) {
    var TotalUP = 0;
    var TotalTC = 0;
    var Units = 0;
    var UnitsPrice = 0;
    for (i = 1; i <= 12; i++) {
           Units = 0;
           UnitsPrice = 0;
           if (document.getElementById(_txtTU + i).value.trim() != '' || document.getElementById(_txtUP + i).value.trim() != '') {

               if (document.getElementById(_txtTU + i).value.trim() == '') {
                   document.getElementById(_txtTU + i).focus();
                   alert('El Total Units debe tener un valor');
                   return false;
               }
               if (document.getElementById(_txtUP + i).value.trim() == '') {
                   document.getElementById(_txtUP + i).focus();
                   alert('Ingrese un valor para el Unit Price');
                   return false;
               }
               Units = redonder2Decimales(Cero(document.getElementById(_txtTU + i).value))
               if (Units <= 0) {
                   alert('el Units debe ser Mayor A Cero');
                   document.getElementById(_txtTU + i).focus();
                   return false;

               }
               UnitsPrice = redonder2Decimales(Cero(document.getElementById(_txtUP + i).value));
               if (UnitsPrice <= 0) {
                   alert('El Unit Price deber ser Mayor A Cero');
                   document.getElementById(_txtUP + i).focus();
                   return false;

               }
               document.getElementById(_txtTC + i).value = redonder2Decimales(document.getElementById(_txtTU + i).value * document.getElementById(_txtUP + i).value);
               TotalUP = redonder2Decimales(TotalUP + document.getElementById(_txtUP + i).value);
               TotalTC = redonder2Decimales(TotalTC + redonder2Decimales(document.getElementById(_txtTC + i).value));


           }
           else {
               document.getElementById(_txtTC + i).value = '';
             
           }
    }
    document.getElementById(_TotalUnitPrice).value =redonder2Decimales(TotalUP);
    document.getElementById(_TotalCost).value =redonder2Decimales(TotalTC);
}
function redonder2Decimales(Monto) { 
return Math.round(parseFloat(Monto) *  100)/100
}
//function TotalUnits(_txtJan, _txtFeb
//, _txtMar, _txtApr, _txtMay
//, _txtJun, _txtJul, _txtAug
//, _txtSep, _txtOct, _txtNov, _txtDec, _txtTotal,
//_txtUsageRageJan, _txtUsageRageFeb
//, _txtUsageRageMar, _txtUsageRageApr, _txtUsageRageMay
//, _txtUsageRageJun, _txtUsageRageJul, _txtUsageRageAug
//, _txtUsageRageSep, _txtUsageRageOct, _txtUsageRageNov, _txtUsageRageDec, _txtUsageRageTotal,
//_txtTotalUnitsJan, _txtTotalUnitsFeb
//, _txtTotalUnitsMar, _txtTotalUnitsApr, _txtTotalUnitsMay
//, _txtTotalUnitsJun, _txtTotalUnitsJul, _txtTotalUnitsAug
//, _txtTotalUnitsSep, _txtTotalUnitsOct, _txtTotalUnitsNov, _txtTotalUnitsDec, _txtTotalUnitsTotal

//) {
//    try {
//        var Jan = document.getElementById(_txtJan).value;
//        var Feb = document.getElementById(_txtFeb).value;
//        var Mar = document.getElementById(_txtMar).value;
//        var Apr = document.getElementById(_txtApr).value;
//        var May = document.getElementById(_txtMay).value;
//        var Jun = document.getElementById(_txtJun).value;
//        var Jul = document.getElementById(_txtJul).value;
//        var Aug = document.getElementById(_txtAug).value;
//        var Sep = document.getElementById(_txtSep).value;
//        var Oct = document.getElementById(_txtOct).value;
//        var Nov = document.getElementById(_txtNov).value;
//        var Dec = document.getElementById(_txtDec).value;
//        var Total = Cero(Jan) + Cero(Feb) + Cero(Mar) + Cero(Apr) + Cero(May) + Cero(Jun) + Cero(Jul) + Cero(Aug) + Cero(Sep) +
//        Cero(Oct) + Cero(Nov) + Cero(Dec);
//        document.getElementById(_txtTotal).value = Total;

//        var UsageRageJan = document.getElementById(_txtUsageRageJan).value;
//        var UsageRageFeb = document.getElementById(_txtUsageRageFeb).value;
//        var UsageRageMar = document.getElementById(_txtUsageRageMar).value;
//        var UsageRageApr = document.getElementById(_txtUsageRageApr).value;
//        var UsageRageMay = document.getElementById(_txtUsageRageMay).value;
//        var UsageRageJun = document.getElementById(_txtUsageRageJun).value;
//        var UsageRageJul = document.getElementById(_txtUsageRageJul).value;
//        var UsageRageAug = document.getElementById(_txtUsageRageAug).value;
//        var UsageRageSep = document.getElementById(_txtUsageRageSep).value;
//        var UsageRageOct = document.getElementById(_txtUsageRageOct).value;
//        var UsageRageNov = document.getElementById(_txtUsageRageNov).value;
//        var UsageRageDec = document.getElementById(_txtUsageRageDec).value;
//        var UsageRageTotal = Cero(UsageRageJan) + Cero(UsageRageFeb) + Cero(UsageRageMar) + Cero(UsageRageApr) + Cero(UsageRageMay) + Cero(UsageRageJun) + Cero(UsageRageJul) + Cero(UsageRageAug) + Cero(UsageRageSep) +
//        Cero(UsageRageOct) + Cero(UsageRageNov) + Cero(UsageRageDec);
//        document.getElementById(_txtUsageRageTotal).value = UsageRageTotal;

//        document.getElementById(_txtTotalUnitsJan).value =redonder2Decimales(Cero(Jan) / Cero(UsageRageJan));
//        document.getElementById(_txtTotalUnitsFeb).value =redonder2Decimales (Cero(Feb) / Cero(UsageRageFeb));
//        document.getElementById(_txtTotalUnitsMar).value =redonder2Decimales (Cero(Mar) / Cero(UsageRageMar));
//        document.getElementById(_txtTotalUnitsApr).value =redonder2Decimales (Cero(Apr) / Cero(UsageRageApr));
//        document.getElementById(_txtTotalUnitsMay).value =redonder2Decimales (Cero(May) / Cero(UsageRageMay));
//        document.getElementById(_txtTotalUnitsJun).value = redonder2Decimales (Cero(Jun) / Cero(UsageRageJun));
//        document.getElementById(_txtTotalUnitsJul).value = redonder2Decimales (Cero(Jul) / Cero(UsageRageJul));
//        document.getElementById(_txtTotalUnitsAug).value = redonder2Decimales (Cero(Aug) / Cero(UsageRageAug));
//        document.getElementById(_txtTotalUnitsSep).value = redonder2Decimales (Cero(Sep) / Cero(UsageRageSep));
//        document.getElementById(_txtTotalUnitsOct).value = redonder2Decimales (Cero(Oct) / Cero(UsageRageOct));
//        document.getElementById(_txtTotalUnitsNov).value = redonder2Decimales (Cero(Nov) / Cero(UsageRageNov));
//        document.getElementById(_txtTotalUnitsDec).value = redonder2Decimales (Cero(Dec) / Cero(UsageRageDec));
//        document.getElementById(_txtTotalUnitsTotal).value = redonder2Decimales(Cero(Total) / Cero(UsageRageTotal));
//        
//        
//        
//        
//    }
//    catch (ex) {
//        alert(ex.message);
//    }
//}


function TotalProduction(_txtJan,_txtFeb
,_txtMar,_txtApr,_txtMay
,_txtJun,_txtJul,_txtAug
,_txtSep,_txtOct,_txtNov,_txtDec,_txtTotal){
    try 
    {
        var Jan=document.getElementById(_txtJan).value;
        var Feb=document.getElementById(_txtFeb).value;
        var Mar=document.getElementById(_txtMar).value;
        var Apr=document.getElementById(_txtApr).value;
        var May=document.getElementById(_txtMay).value;
        var Jun=document.getElementById(_txtJun).value;
        var Jul=document.getElementById(_txtJul).value;
        var Aug=document.getElementById(_txtAug).value;
        var Sep=document.getElementById(_txtSep).value;
        var Oct=document.getElementById(_txtOct).value;
        var Nov=document.getElementById(_txtNov).value; 
        var Dec=document.getElementById(_txtDec).value; 
        
        var Total= Cero(Jan) + Cero(Feb)+Cero(Mar) +Cero(Apr)+Cero(May)+ Cero(Jun)+ Cero(Jul) + Cero(Aug) + Cero(Sep) + 
        Cero(Oct) + Cero(Nov) + Cero(Dec) ;
        document.getElementById(_txtTotal).value=Total;
    }
    catch(ex)
    {
    alert(ex.message);
    }
}


function ManejoNullsString(Valor)
{
  if(Valor.trim()=='NaN' || Valor.trim()=='')
  {
   return   Valor="0";
  }
  else
  {
  return Valor;
  }
}



function HabilitarControlesActualProduction(estado,Limpiar,Deshabilitar,_txtJan,_txtFeb
,_txtMar,_txtApr,_txtMay
,_txtJun,_txtJul,_txtAug
,_txtSep,_txtOct,_txtNov,_txtDec,_Total){
    try{
    
   switch (Limpiar)
   {
        case true : 
        document.getElementById(_txtJan).innerText = ""; 
        document.getElementById(_txtFeb).value = "";
        document.getElementById(_txtMar).value = "";
        document.getElementById(_txtApr).value = "";
        document.getElementById(_txtMay).value = "";
        document.getElementById(_txtJun).value = "";
        document.getElementById(_txtJul).value = "";
        document.getElementById(_txtAug).value = "";
        document.getElementById(_txtSep).value = "";
        document.getElementById(_txtOct).value = "";
        document.getElementById(_txtNov).value = "";
        document.getElementById(_txtDec).value = "";
        document.getElementById(_Total).value = "";        
        break;
   }
   switch  (Deshabilitar)
    {
      case true:
        document.getElementById(_txtJan).disabled = estado;
        document.getElementById(_txtFeb).disabled = estado;
        document.getElementById(_txtMar).disabled = estado;
        
        document.getElementById(_txtApr).disabled = estado;
        document.getElementById(_txtMay).disabled = estado;
        document.getElementById(_txtJun).disabled = estado;
        document.getElementById(_txtJul).disabled = estado;
        document.getElementById(_txtAug).disabled = estado;
        document.getElementById(_txtSep).disabled = estado;
        document.getElementById(_txtOct).disabled = estado;
        document.getElementById(_txtNov).disabled = estado;
        document.getElementById(_txtDec).disabled = estado;
        document.getElementById(_Total).disabled = estado;
      
      break;
    }
   
     }catch(ex){
        alert(ex.message);
    } 
}


//function HabilitarControlesLocation(estado, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12, id13, id14, id15, id16, id17, id18, id19){
//    try{
//        document.getElementById(id1).disabled = estado;
//        document.getElementById(id2).disabled = estado;
//        document.getElementById(id2).innerText = "";
//        document.getElementById(id3).disabled = estado;
//        document.getElementById(id3).value = "";
//        document.getElementById(id4).disabled = estado;
//        document.getElementById(id4).parentNode.disabled = estado;
//        document.getElementById(id4).checked = false;
//        document.getElementById(id5).disabled = estado;
//        document.getElementById(id5).value = "";
//        document.getElementById(id6).disabled = estado;
//        //document.getElementById(id6).value = "0";
//        document.getElementById(id7).disabled = estado;
//        
//        
//        document.getElementById(id7).value = "";
//        document.getElementById(id8).disabled = estado;
//        document.getElementById(id8).value = "";
//        document.getElementById(id9).disabled = estado;
//        document.getElementById(id9).value = "";
//        document.getElementById(id10).disabled = estado;
//        document.getElementById(id10).value = "";
//        document.getElementById(id11).disabled = estado;
//        document.getElementById(id11).value = "";
//        document.getElementById(id12).disabled = estado;
//        document.getElementById(id12).value = "";
//        document.getElementById(id13).disabled = estado;
//        document.getElementById(id13).value = "";
//        document.getElementById(id14).disabled = estado;
//        document.getElementById(id14).value = "";
//        document.getElementById(id15).disabled = estado;
//        //document.getElementById(id15).value = "0";
//        document.getElementById(id16).disabled = estado;
//        document.getElementById(id16).value = "";
//        document.getElementById(id17).disabled = estado;
//        //document.getElementById(id17).value = "";
//        document.getElementById(id18).disabled = estado;
//        document.getElementById(id18).value = "";
//        document.getElementById(id19).value = "Save";                  
//        document.getElementById(id1).focus();     
//    }catch(ex){
//        alert(ex.message);
//    }
//}

//function HabilitarControlesVendor(estado, id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12, id13, id14, id15, id16, id17, id18, id19, id20, id21, id22) {
//    try {
//        document.getElementById(id1).disabled = estado;
//        document.getElementById(id2).disabled = estado;
//        document.getElementById(id2).innerText = "0";
//        document.getElementById(id3).disabled = estado;
//        document.getElementById(id3).innerText = "N";
//        document.getElementById(id4).disabled = estado;
//        document.getElementById(id4).value = "";               
//        document.getElementById(id5).disabled = estado;
//        document.getElementById(id5).parentNode.disabled = estado;
//        document.getElementById(id5).checked = false;
//        document.getElementById(id6).disabled = estado;
//        document.getElementById(id6).value = "";
//        document.getElementById(id7).disabled = estado;
//        document.getElementById(id7).parentNode.disabled = estado;
//        document.getElementById(id7).checked = false;        
//        document.getElementById(id8).disabled = estado;
//        document.getElementById(id8).value = "";
//        document.getElementById(id9).disabled = estado;
//        document.getElementById(id9).value = "";
//        document.getElementById(id10).disabled = estado;
//        document.getElementById(id10).value = "";
//        document.getElementById(id11).disabled = estado;
//        document.getElementById(id11).value = "";
//        document.getElementById(id12).disabled = estado;
//        document.getElementById(id12).value = "";
//        document.getElementById(id13).disabled = estado;
//        document.getElementById(id13).value = "";
//        document.getElementById(id14).disabled = estado;
//        document.getElementById(id14).value = "";
//        document.getElementById(id15).disabled = estado;
//        document.getElementById(id15).value = "";
//        document.getElementById(id16).disabled = estado;
//        document.getElementById(id16).value = "";        
//        document.getElementById(id17).disabled = estado;
//        document.getElementById(id18).disabled = estado;
//        document.getElementById(id18).value = "";
//        document.getElementById(id19).disabled = estado;
//        document.getElementById(id20).disabled = estado;
//        document.getElementById(id20).value = "";
//        document.getElementById(id21).value = "Save";
//        document.getElementById(id22).disabled = ((estado==false)?false:true);
//        document.getElementById(id1).focus();
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function AsignarDatosLocation(val1, val2, val3, val4, val5, val6, val7, val8, val9, val10, val11, val12, val13, val14, val15, val16, val17, val18,
//                               id1,  id2,  id3,  id4,  id5,  id6,  id7,  id8,  id9,  id10,  id11,  id12,  id13,  id14,  id15,  id16,  id17,  id18, id19){
//    try{
//        HabilitarControlesLocation(false, id1,  id2,  id3,  id4,  id5,  id6,  id7,  id8,  id9,  id10,  id11,  id12,  id13,  id14,  id15,  id16,  id17,  id18, id19)    
//        document.getElementById(id1).innerText = val1;
//        document.getElementById(id2).innerText = val2;
//        document.getElementById(id3).value = val3;
//        document.getElementById(id4).checked = ((val4 == 1) ? false : true) ;
//        document.getElementById(id5).value = val5;
//        document.getElementById(id6).value = val6;
//        document.getElementById(id7).value = val7;
//        document.getElementById(id8).value = val8;
//        document.getElementById(id9).value = val9;
//        document.getElementById(id10).value = val10;
//        document.getElementById(id11).value = val11;
//        document.getElementById(id12).value = val12;
//        document.getElementById(id13).value = val13;
//        document.getElementById(id14).value = val14;
//        document.getElementById(id15).value = val15;
//        document.getElementById(id16).value = val16;
//        document.getElementById(id17).value = val17;
//        document.getElementById(id18).value = val18;
//        document.getElementById(id19).value = "Update";
//         
//    }catch(ex){
//        alert(ex.message);
//    }
//}

//function AsignarDatosContacts(val1, val2, val3, val4, val5, val6, val7, val8, val9, val10, val11, val12, val13, val14, val15, val16, val17, val18, val19, val20,
//                               id1,  id2,  id3,  id4,  id5,  id6,  id7,  id8,  id9,  id10,  id11,  id12,  id13,  id14,  id15,  id16,  id17,  id18, id19, id20, id21){
//    try{
//        HabilitarControles(false, id3,  id4,  id5,  id6,  id7,  id8,  id9,  id10,  id11,  id12,  id13,  id14,  id15,  id16,  id17,  id18, id19, id20, id21, id1)    
//        document.getElementById(id1).innerText = val1;
//        document.getElementById(id2).innerText = val2;
//        document.getElementById(id3).value = val3;
//        document.getElementById(id4).checked = ((val4 == 1) ? false : true) ;
//        document.getElementById(id5).value = val5;
//        document.getElementById(id6).value = val6;
//        document.getElementById(id7).value = val7;
//        document.getElementById(id8).value = val8;
//        document.getElementById(id9).value = val9;
//        document.getElementById(id10).value = val10;
//        document.getElementById(id11).value = val11;
//        document.getElementById(id12).value = val12;
//        document.getElementById(id13).value = val13;
//        document.getElementById(id14).value = val14;
//        document.getElementById(id15).value = val15;
//        document.getElementById(id16).value = val16;
//        document.getElementById(id17).value = val17;
//        document.getElementById(id18).value = val18;
//        document.getElementById(id19).value = val19;
//        document.getElementById(id20).checked = ((val20 == 1) ? false : true) ;
//        document.getElementById(id21).value = "Update";
//         
//    }catch(ex){
//        alert(ex.message);
//    }
//}

//function AsignarDatosContactsVendor(val1, val2, val3, val4, val5, val6, val7, val8, val9, val10, val11, val12, val13, val14, val15,
//                                     id1,  id2,  id3,  id4,  id5,  id6,  id7,  id8,  id9,  id10,  id11,  id12,  id13,  id14,  id15,  id16){
//    try{
//        HabilitarControlesVendorContacts(false, id1, id3,  id4,  id5,  id6,  id7,  id8,  id9,  id10,  id11,  id12,  id13,  id14,  id15, id16)
//        document.getElementById(id1).innerText = val1;
//        document.getElementById(id2).innerText = val2;
//        document.getElementById(id3).value = val3;
//        document.getElementById(id4).checked = ((val4 == 1) ? false : true) ;
//        document.getElementById(id5).value = val5;
//        document.getElementById(id6).value = val6;
//        document.getElementById(id7).value = val7;
//        document.getElementById(id8).value = val8;
//        document.getElementById(id9).value = val9;
//        document.getElementById(id10).value = val10;
//        document.getElementById(id11).value = val11;
//        document.getElementById(id12).value = val12;
//        document.getElementById(id13).value = val13;
//        document.getElementById(id14).value = val14;
//        document.getElementById(id15).value = val15;
//        document.getElementById(id16).value = "Update";
//        
//    }catch(ex){
//        alert(ex.message);
//    }
//}

//function AsignarDatosAvailableTC(val1, val2, val3, val4, val5,
//                                 id1, id2, id3, id4, id5, id6) {
//    try {       
//        document.getElementById(id1).value = val1;
//        document.getElementById(id2).value = val2;
//        //document.getElementById(id3).innerHTML = document.getElementById(id6).value.split('|')[val5];
//        document.getElementById(id4).value = val4;
//        document.getElementById(id5).value = val4;
//    } catch (ex) {
//        alert(ex.message);
//    }
//}

//function abreventanaMax( aURL, aWinName ){
//    var wOpen;
//    var sOptions;
//        
//    sOptions = 'directories=no,status=no,toolbar=no,menubar=no,scrollbars=no';
//    sOptions = sOptions + ',resizable=no,location=no,maximize=yes';
//    sOptions = sOptions + ',width=' + (screen.availWidth - 12).toString();
//    sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
//    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
//        
//    wOpen = window.open( '', aWinName, sOptions );
//    wOpen.location = aURL;
//    wOpen.focus();
//    wOpen.moveTo( 0, 0 );
//    wOpen.resizeTo( screen.availWidth, screen.availHeight );
//    return wOpen;
//}

//function SalirIFrame() {
//    window.parent.MDI.document.body.innerText = '';
//}

//function ini() {
//    document.getElementById("MDI").width = document.frames.MDI.document.body.offsetWidth + document.frames.MDI.document.body.scrollWidth;
//    document.getElementById("MDI").height = document.frames.MDI.document.body.offsetHeight + document.frames.MDI.document.body.scrollHeight;
//}

function limpiaForm(miForm) {
// recorremos todos los campos que tiene el formulario
$(':input', miForm).each(function() {
var type = this.type;
var tag = this.tagName.toLowerCase();
//limpiamos los valores de los campos…
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
// excepto de los checkboxes y radios, le quitamos el checked
// pero su valor no debe ser cambiado
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
// los selects le ponesmos el indice a -
//else if (tag == 'select')
//this.selectedIndex = -1;
});
}

function TotalizarForward(_txtJAN0, _txtJAN, _txtFEB
, _txtMAR, _txtAPR, _txtMAY
, _txtJUN, _txtJUL, _txtAUG
, _txtSEP, _txtOCT, _txtNOV, _txtDEC, _txtTotal, _txtT) {
    var TBudget = 0;
    var TJan = 0;
    var TFeb = 0;
    var TMar = 0;
    var TApr = 0;
    var TMay = 0;
    var TJun = 0;
    var TJul = 0;
    var TAug = 0;
    var TSet = 0;
    var TOct = 0;
    var TNov = 0;
    var TDec = 0;
    for (i = 1; i <= 12; i++) {

        switch (i) {
            case 1:
                for (j = 1; j <= 12; j++) {
                    TBudget += (document.getElementById(_txtJAN0 + j).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN0 + j).value);
                }

                var uno = document.getElementById(_txtAPR + i).value;
                var dos = document.getElementById(_txtMAY + i).value;
                var tres = document.getElementById(_txtJAN + i).value;
                var cuatro = document.getElementById(_txtJUL + i).value;
                var cinco = document.getElementById(_txtAUG + i).value;

                TJan += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TJan += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TJan += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TJan += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TJan += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TJan += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TJan += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TJan += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TJan += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TJan += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TJan += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TJan += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);

                break;
            case 2:
                TFeb += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TFeb += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TFeb += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TFeb += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TFeb += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TFeb += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TFeb += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TFeb += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TFeb += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TFeb += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TFeb += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TFeb += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;
            case 3:
                TMar += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TMar += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TMar += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TMar += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TMar += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TMar += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TMar += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TMar += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TMar += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TMar += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TMar += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TMar += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;
            case 4:
                TApr += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TApr += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TApr += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TApr += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TApr += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TApr += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TApr += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TApr += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TApr += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TApr += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TApr += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TApr += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;
            case 5:
                TMay += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TMay += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TMay += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TMay += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TMay += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TMay += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TMay += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TMay += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TMay += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TMay += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TMay += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TMay += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;
            case 6:
                TJun += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TJun += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TJun += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TJun += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TJun += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TJun += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TJun += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TJun += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TJun += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TJun += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TJun += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TJun += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;
            case 7:
                TJul += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TJul += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TJul += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TJul += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TJul += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TJul += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TJul += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TJul += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TJul += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TJul += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TJul += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TJul += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;
            case 8:
                TAug += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TAug += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TAug += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TAug += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TAug += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TAug += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TAug += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TAug += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TAug += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TAug += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TAug += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TAug += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                
                break;
            case 9:
                TSet += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TSet += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TSet += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TSet += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TSet += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TSet += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TSet += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TSet += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TSet += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TSet += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TSet += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TSet += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                
                break;
            case 10:
                TOct += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TOct += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TOct += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TOct += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TOct += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TOct += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TOct += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TOct += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TOct += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TOct += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TOct += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TOct += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                
                break;
            case 11:
                TNov += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TNov += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TNov += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TNov += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TNov += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TNov += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TNov += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TNov += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TNov += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TNov += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TNov += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TNov += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                
                
                break;
            case 12:
                TDec += (document.getElementById(_txtJAN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJAN + i).value);
                TDec += (document.getElementById(_txtFEB + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtFEB + i).value);
                TDec += (document.getElementById(_txtMAR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAR + i).value);
                TDec += (document.getElementById(_txtAPR + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAPR + i).value);
                TDec += (document.getElementById(_txtMAY + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtMAY + i).value);
                TDec += (document.getElementById(_txtJUN + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUN + i).value);
                TDec += (document.getElementById(_txtJUL + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtJUL + i).value);
                TDec += (document.getElementById(_txtAUG + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtAUG + i).value);
                TDec += (document.getElementById(_txtSEP + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtSEP + i).value);
                TDec += (document.getElementById(_txtOCT + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtOCT + i).value);
                TDec += (document.getElementById(_txtNOV + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtNOV + i).value);
                TDec += (document.getElementById(_txtDEC + i).value.trim() == '') ? 0 : parseFloat(document.getElementById(_txtDEC + i).value);
                break;

        }

    }

    document.getElementById(_txtTotal).value = TBudget;
    document.getElementById(_txtT + 1).value = TJan;
    document.getElementById(_txtT + 2).value = TFeb;
    document.getElementById(_txtT + 3).value = TMar;
    document.getElementById(_txtT + 4).value = TApr;
    document.getElementById(_txtT + 5).value = TMay;
    document.getElementById(_txtT + 6).value = TJun;
    document.getElementById(_txtT + 7).value = TJul;
    document.getElementById(_txtT + 8).value = TAug;
    document.getElementById(_txtT + 9).value = TSet;
    document.getElementById(_txtT + 10).value = TOct;
    document.getElementById(_txtT + 11).value = TNov;
    document.getElementById(_txtT + 12).value = TDec;

}

function AsignarRowFrmFindLogin(c) {
    try {
        //var arra = Array();
        //arra = c.split(',');
        window.dialogArguments.dialogValue1 = c;
        //window.dialogArguments.dialogValue2 = arra[1];
        //window.dialogArguments.dialogValue3 = arra[2];
        window.returnValue = true;
        window.close();

    } catch (ex) {
        alert(ex.message);
    }
}